﻿//-----------------------------------------------------------------
//
// @(#)$Id: EbayActiveListingDetail.aspx.cs,v 1.0 2013/12/13 17:14:07 lichunhua Exp $
// @(#)$Author: lichunhua  $
// @(#)$Date: 2013/12/13 17:14:07 $
// @(#)$Description:
//
//
//
//                 All Rights Reserved.
//-----------------------------------------------------------------
using System;
using System.Data;
using ebay.BLL;
using ebay.Dal.CenterDB_EbayTableAdapters;

public partial class UI_Bas_EbayActiveListingDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string act = Request.QueryString["act"];
            if (!string.IsNullOrEmpty(act))
            {
                switch (act)
                {
                    case "view":
                        string itemId = Request.QueryString["id"];
                        string ebayUserId = Request.QueryString["id2"];
                        T_EbayActiveListingTableAdapter ebayAdapter = new T_EbayActiveListingTableAdapter();
                        DataTable dt = ebayAdapter.GetDataById(ebayUserId, itemId);
                        if (dt.Rows.Count > 0)
                        {
                            T_EbayAccountTableAdapter accountAdapter = new T_EbayAccountTableAdapter();
                            DataTable tToken = accountAdapter.GetDataByEbayUserId(ebayUserId);
                            if (tToken.Rows.Count > 0)
                            {
                                string token = tToken.Rows[0]["Token"].ToString();
                                EbayActiveListing bllActiveListing = new EbayActiveListing();
                                ebay.Model.EbayActiveListing item = bllActiveListing.GetItem(itemId, ebayUserId, token);
                                if (item == null)
                                    return;

                                DataRow r = dt.Rows[0];

                                txtBids.Value = r["Bids"].ToString();
                                txtCategoryLeafName.Value = item.CategoryLeafName;
                                txtCategoryNumber.Value = item.CategoryNumber.ToString();
                                txtCondition.Value = item.Condition.ToString();
                                txtConditionID.Value = item.ConditionID.ToString();
                                txtCustomLable.Value = r["CustomLable"].ToString();
                                txtEndDate.Value = Convert.ToDateTime(r["EndDate"]).ToString("yyyy-MM-dd") == "1900-01-01" ? "" : r["EndDate"].ToString();
                                txtItemId.Value = r["ItemId"].ToString();
                                txtItemTitle.Value = r["ItemTitle"].ToString();
                                txtPrice.Value = r["Price"].ToString();
                                txtPrivateNotes.Value = item.PrivateNotes;
                                txtProductIDType.Value = item.ProductIDType;
                                txtProductIDValue.Value = item.ProductIDValue;
                                txtProductIDValue2.Value = item.ProductIDValue2;
                                txtProductReferenceID.Value = item.ProductReferenceID;
                                txtPurchases.Value = r["Purchases"].ToString();
                                txtQuantityAvailable.Value = r["QuantityAvailable"].ToString();
                                txtSiteListed.Value = item.SiteListed;
                                txtStartDate.Value = r["StartDate"].ToString();
                                txtType.Value = r["Type"].ToString();
                                txtVariationDetails.Value = item.VariationDetails;
                            }
                        }
                        break;
                }
            }
        }
    }
}

